package com.lucan.tracking.plugin.visitor.anno

import org.objectweb.asm.AnnotationVisitor


abstract class AbsAnnoVisitor extends AnnotationVisitor{

    private String mDesc
    private Closure mClosure
    private Map<String, String> mValueMap = new HashMap<>()

    AbsAnnoVisitor(int api, AnnotationVisitor av, String desc, Closure closure) {
        super(api, av)
        println "api:$api,desc:$desc===========ConfigurationAnnoVisitor"
        mDesc = desc
        mClosure = closure
    }

    @Override
    void visit(String name, Object value) {
        super.visit(name, value)
        println "$mDesc, name:$name, value:$value===========visit"
        mValueMap.put(name, value == null ? "" : value.toString())
    }

    @Override
    void visitEnum(String name, String desc, String value) {
        super.visitEnum(name, desc, value)
        println "$mDesc, name:$name, desc:$desc, value:$value===========visitEnum"
        mValueMap.put(name, value ? value : "")

    }

    @Override
    void visitEnd() {
        super.visitEnd()
        mClosure?.call(mValueMap)
    }
}
